// es 中 import 语法，引入模块 Vue 核心库
import Vue from "vue";
// vue-router 核心库
import VueRouter from "vue-router";
// 引入一个组件
import HomeView from "../views/HomeView.vue";
// vue 中一个插件
// Vue.use(VueRouter)
Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "home",
    component: HomeView,
    meta: {
      title: "主页",
    },
  },
  {
    path: "/vod",
    name: "vod",
    component: () => import("../views/VodView"),
    meta: {
      title: "全部视频",
    },
  },
  {
    path: "/vod/detail",
    name: "detail",
    component: () => import("../views/DetaileView.vue"),
    meta: {
      title: "课程详情",
    },
  },
  {
    path: "/study",
    name: "study",
    component: () => import("../views/StudyView.vue"),
    meta: {
      title: "在学",
    },
  },
  {
    path: "/member",
    name: "member",
    component: () => import("../views/MemberView.vue"),
    meta: {
      title: "我的",
    },
  },
  {
    path: "/login-password",
    name: "login-password",
    component: () => import("../views/LoginPasswordView.vue"),
    meta: {
      title: "密码登录",
    },
  },
  {
    path: "/member/role",
    name: "role",
    component: () => import("../views/RoleView"),
    meta: {
      title: "vip会员",
      auth: true,
    },
  },
  {
    path: "/member/profile",
    name: "profile",
    component: () => import("../views/ProfileView"),
    meta: {
      title: "个人资料",
      auth: true,
    },
  },
  {
    path: "/member/setting",
    name: "setting",
    component: () => import("../views/SettingView"),
    meta: {
      title: "设置",
    },
  },
  {
    path: "/message",
    name: "message",
    component: () => import("../views/MessageView"),
    meta: {
      title: "我的消息",
      auth: true,
    },
  },
  {
    path: "/member/order",
    name: "order",
    component: () => import("../views//OrderView"),
    meta: {
      title: "我的订单",
      auth: true,
    },
  },
  {
    path: "/member/promocode",
    name: "promocode",
    component: () => import("../views//PromocodeView"),
    meta: {
      title: "我的邀请码",
      auth: true,
    },
  },
  {
    path: "/about",
    name: "about",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  },
];

// 创建一个路由的实例
const router = new VueRouter({
  routes,
});
// 通过es6 export 语法将路由模块进行导出
export default router;
